﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Web.Services;
using System.Web;
using System.Data;
using System.Configuration;
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Data.SqlClient;
using System.Drawing;
using System.Net.Mail;

using System.Web.Services;


public partial class partner_partner_update_property : System.Web.UI.Page
{
    private byte[] ConvertImageToByteArray(System.Drawing.Image imageToConvert, System.Drawing.Imaging.ImageFormat formatOfImage)
    {
        byte[] Ret;
        try
        {
            using (MemoryStream ms = new MemoryStream())
            {
                imageToConvert.Save(ms, formatOfImage);
                Ret = ms.ToArray();
            }
        }
        catch (Exception) { throw; }
        return Ret;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        txtRooms.Text = "0";
        TextBox16.Text = "0";
        txtAssetAmount.Text = "N/A";
        if (Session["email"] == null)
        {
            Response.Redirect("sessiont.aspx");
        }
        string ss = "S72461022";
        Label1.Text = Session["email"].ToString();
        if (Page.IsPostBack)
        {
        }
        else
        {
            SqlConnection conn = null;
            conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);


            conn.Open();
            SqlCommand scmd = new SqlCommand("SELECT * FROM properties where p_id='" +Session["p_id"] + "'", conn);

            SqlDataReader dr = scmd.ExecuteReader();
            if (dr.Read())
            {

                txtfname1.Text = dr[3].ToString();
                txtmname.Text = dr[4].ToString();
                txtlname1.Text = dr[5].ToString();
                txtdob1.Text = dr[6].ToString();
                txtoccupation.Text = dr[7].ToString();
                txthno.Text = dr[8].ToString();
                txtcity.Text = dr[9].ToString();
                TextBox3.Text = dr[10].ToString();
                txtssn.Text = dr[11].ToString();
                txtzip.Text = dr[12].ToString();
                txtcountry.Text = dr[13].ToString();


                TextBox5.Text = dr[17].ToString();
                txtBlock.Text = dr[18].ToString();
                txtSub.Text = dr[19].ToString();
                txtZone.Text = dr[20].ToString();
                txtAssetAmount.Text = dr[21].ToString();
                txtBuildPrivilege.Text = dr[22].ToString();




                txtGeneralArea.Text = dr[23].ToString();
                txtRoom.Text = dr[24].ToString();
                txtBlockA.Text = dr[25].ToString();
                txtBlockB.Text = dr[26].ToString();
                txtBlockC.Text = dr[27].ToString();
                TextBox12.Text = dr[28].ToString();
                txtpark.Text = dr[31].ToString();
                txtfurniture.Text = dr[33].ToString();


                txttoilets.Text = dr[35].ToString();
                TextBox16.Text = dr[37].ToString();
                TextBox8.Text = dr[39].ToString();
                TextBox11.Text = dr[42].ToString();
                TextBox15.Text = dr[44].ToString();
                TextBox7.Text = dr[46].ToString();
                TextBox10.Text = dr[48].ToString();
                TextBox17.Text = dr[51].ToString();
                txtProperty.Text = dr[51].ToString();
                txtCity1.Text = dr[52].ToString();
                txtStreet.Text = dr[53].ToString();
                txtPrice.Text = dr[54].ToString();
                txtOldPrice.Text = dr[55].ToString();
                txtColor.Text = dr[56].ToString();
                txtRooms.Text = dr[57].ToString();
                txtPremises.Text = dr[58].ToString();
                txtAge.Text = dr[59].ToString();
                txtPropertyTax.Text = dr[60].ToString();
                txtRentEstimate.Text = dr[61].ToString();
                txtAdditions.Text = dr[62].ToString();

                txtLevel.Text = dr[64].ToString();




                TextBox6.Text = dr[68].ToString();
                TextBox19.Text = dr[84].ToString();
                TextBox20.Text = dr[100].ToString();
                TextBox9.Text = dr[69].ToString();
                txtRooms2.Text = dr[73].ToString();
                txtPremises2.Text = dr[74].ToString();

                txtAge2.Text = dr[75].ToString();
                txtPropertyTax2.Text = dr[76].ToString();
                txtRentingEstimate2.Text = dr[77].ToString();
                txtAdditions2.Text = dr[78].ToString();


                TextBox13.Text = dr[86].ToString();
                TextBox14.Text = dr[102].ToString();



                txtLevel2.Text = dr[80].ToString();




                txtRooms3.Text = dr[89].ToString();
                txtPremises3.Text = dr[90].ToString();
                txtAge3.Text = dr[91].ToString();
                txtPropertyTax3.Text = dr[92].ToString();
                txtRentingEstimate3.Text = dr[93].ToString();
                txtAdditions3.Text = dr[94].ToString();

                txtLevel3.Text = dr[96].ToString();
                txtStrongRoom3.Text = dr[0].ToString();
                txtAC3.Text = dr[0].ToString();
                txtBalconies3.Text = dr[0].ToString();










            }


            dr.Close();
        }
    }





    protected void Save_Click(object sender, EventArgs e)
    {

        SqlConnection conn = null;
        conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn.Open();

        SqlCommand cm1 = new SqlCommand("update properties set  type='" + DropDownList5.SelectedValue + "', fname='" + txtfname1.Text + "',  mname='" + txtmname.Text + "', lname='" + txtlname1.Text + "', dob='" + txtdob1.Text + "',occupation='" + txtoccupation.Text + "', houseno='" + txthno.Text + "', city='" + txtcity.Text + "', street='" + TextBox3.Text + "',  ssn='" + txtssn.Text + "',  zip='" + txtzip.Text + "',country='" + txtcountry.Text + "',prop_type='" + DropDownList5.SelectedValue + "', cust_proptype='" + DropDownList7.SelectedValue + "', prop_cond='" + DropDownList8.SelectedValue + "', cust_prop_cond='" + TextBox5.Text + "',block='" + txtBlock.Text + "',sub='" + txtSub.Text + "', zone='" + txtZone.Text + "', asset_amount='" + txtAssetAmount.Text + "', b_privelege='" + txtBuildPrivilege.Text + "', g_area='" + txtGeneralArea.Text + "', room='" + txtRoom.Text + "',   elevator='" + txtBlockA.Text + "',  roof='" + txtBlockB.Text + "', electric='" + txtBlockC.Text + "',no_of_residence='" + TextBox12.Text + "', parking='" + ddlparking.SelectedValue + "',  custom_park='" + txtpark.Text + "', furniture='" + DropDownList18.SelectedValue + "', custom_furniture='" + txtfurniture.Text + "',toilet='" + DropDownList19.SelectedValue + "',custom_toilet='" + txttoilets.Text + "',shower='" + DropDownList20.SelectedValue + "', custom_shower='" + TextBox16.Text + "',kitchen='" + DropDownList10.SelectedValue + "', view_prop='" + DropDownList11.SelectedValue + "', custom_view='" + TextBox8.Text + "', front_rear_view='" + DropDownList16.SelectedValue + "',custom_front_rear='" + TextBox11.Text + "', garden='" + DropDownList24.SelectedValue + "', custom_garden='" + TextBox15.Text + "', evacuation_date='" + DropDownList12.SelectedValue + "',  custome_evacuation_date='" + TextBox7.Text + "',land='" + DropDownList15.SelectedValue + "', custom_land='" + TextBox10.Text + "',   area='" + DropDownList25.SelectedValue + "', custom_area='" + TextBox17.Text + "', p_property='" + txtProperty.Text + "',  p_city='" + txtCity1.Text + "',p_street='" + txtStreet.Text + "', p_price='" + txtPrice.Text + "',  p_oldprice='" + txtOldPrice.Text + "', p_color='" + txtColor.Text + "', p_rooms='" + txtRooms.Text + "', p_premises='" + txtPremises.Text + "',p_age='" + txtAge.Text + "',  p_prop_tax='" + txtPropertyTax.Text + "',p_renting_estimate='" + txtRentEstimate.Text + "', p_additions='" + txtAdditions.Text + "', p_basement='" + txtBasement.Text + "',  p_level='" + txtLevel.Text + "', p_strong='" + txtStrong.Text + "',   p_ac='" + txtAC.Text + "', p_balconies='" + txtBalconies.Text + "', p_balcony_area='" + TextBox6.Text + "', p_balconie_no='" + DropDownList9.SelectedValue + "', p_maintance='" + TextBox9.Text + "', p_building='" + DropDownList13.SelectedValue + "',  p_boiler='" + DropDownList14.SelectedValue + "',p_rooms2='" + txtRooms2.Text + "', p_premises2='" + txtPremises2.Text + "', p_age2='" + txtAge2.Text + "', p_prop_tax2='" + txtPropertyTax2.Text + "',p_renting_estimate2='" + txtRentingEstimate2.Text + "',p_additions2='" + txtAdditions2.Text + "',  p_basement2='" + txtBasement2.Text + "', p_level2='" + txtLevel2.Text + "', p_strong2='" + txtStrongRoom2.Text + "',  p_ac2='" + txtAC2.Text + "', p_balconies2='" + txtBalcony2.Text + "',p_balcony_area2='" + TextBox19.Text + "',p_balconie_no2='" + DropDownList26.SelectedValue + "',p_rooms3='" + txtRooms3.Text + "', p_premises3='" + txtPremises3.Text + "',   p_age3='" + txtAge3.Text + "',  p_prop_tax3='" + txtPropertyTax3.Text + "', p_renting_estimate3='" + txtRentingEstimate3.Text + "', p_additions3='" + txtAdditions3.Text + "',p_basement3='" + txtBasement3.Text + "',p_level3='" + txtLevel3.Text + "',p_strong3='" + txtStrongRoom3.Text + "',  p_ac3='" + txtAC3.Text + "', p_balconies3='" + txtBalconies3.Text + "',p_balcony_area3='" + TextBox20.Text + "',p_balconie_no3='" + DropDownList27.SelectedValue + "',p_north='" + CheckBox9.Checked + "',p_south='" + CheckBox10.Checked + "',  p_east='" + CheckBox11.Checked + "',p_west='" + CheckBox12.Checked + "', p_smart='" + CheckBox1.Checked + "', p_alarm='" + CheckBox2.Checked + "', p_bars='" + CheckBox3.Checked + "', p_handi='" + CheckBox4.Checked + "',   p_teather='" + CheckBox5.Checked + "', p_gym='" + CheckBox6.Checked + "',   p_zacuji='" + CheckBox7.Checked + "',  p_pool='" + CheckBox8.Checked + "', adding_date='" + System.DateTime.Now + "',  adding_by='" + Session["email"] + "'", conn);
        cm1.ExecuteNonQuery();
        Response.Redirect("partner_update_property_conf.aspx");
        conn.Close();
    }
    protected void LinkButton1_Click(object sender, System.EventArgs e)
    {
        Session.Abandon();
        Response.Redirect("../partner.aspx");
    }
}